<template>
	<view class="Menu">
		<!-- 导航条 :style="{ height: $wanlshop.wanlsys().height + 'px' }"-->
		<view class="cu-custom">
			<view class="cu-bar fixed bg-bgcolor"
				:style="{height: $wanlshop.wanlsys().height + 'px',paddingTop: $wanlshop.wanlsys().top + 'px',}">
				<view class="action">
					<text class="wlIcon-fanhui1" style="margin-left: 0" @tap="$wanlshop.back(1)"></text>
				</view>
				<view class="content" :style="{ top: $wanlshop.wanlsys().top + 'px' }">
					闪兑
				</view>
				<view class="action">
					<text class="wlIcon-gengduo"></text>
				</view>
			</view>
		</view>
		<view class="listbox">
			<view class="bg">
				<view class="assets">
					<view class="assetsT">
						<view class="title">消耗</view>
						<view class="pick">
							可用：{{money||0.00}} YLDA
						</view>
					</view>
					<view class="assetsM">
						<view class="assetsmMoney">
							YLDA
						</view>
						<view class="assetsInput">
							<u--input border='none' v-model="Inputmoney" @blur='blur'></u--input>
						</view>

					</view>
				</view>
			</view>
			<view class="bg">
				<view class="assets">
					<view class="assetsT">
						<view class="title">获得</view>
					</view>
					<view class="assetsM">
						<view class="assetsmMoney">
							USDT
						</view>
						<view class="assetsInput">
							<view class="Inputmoney1" style="text-align: right;">
								{{Inputmoney1}}
							</view>
						</view>

					</view>
				</view>
			</view>
			<view class="dhJT">
				<u-icon name="arrow-downward" size="20" style="margin-top: 20rpx;"></u-icon>
				<u-icon name="arrow-upward" size="20" class='up'></u-icon>
			</view>
		</view>
		<view class="uni-btn">
			<button class="uni-btn-v" @click="formSubmit">闪兑</button>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				num: '0',
				Inputmoney: '0',
				Inputmoney1: '0',
				money: '',
				id: '77',
				unitPrice: ''
			};
		},
		onShow() {
			this.getMoney()
			this.usdtbl()
		},
		methods: {
			getMoney() {
				uni.request({
					url: "/user/getMoney",
					method: 'POST',
					data: {
						type: '77',
					},
					success: (res) => {
						if (res.res.code == 1) {
							this.money = res.res.data.money
						}
					},
				});
			},
			usdtbl() {
				uni.request({
					url: "/user/usdtbl",
					method: 'POST',
					success: (res) => {
						if (res.res.code == 1) {
							if (this.id == '77') {
								this.unitPrice = res.res.data.usdt_ylda_value

							}
						}
					},
				});
			},
			usdtblreMoney() {
				uni.request({
					url: "/user/usdtblMoney",
					method: 'POST',
					data: {
						type: '77',
						money: this.Inputmoney,
						unit_price: this.unitPrice
					},
					success: (res) => {
						if (res.res.code == 1) {
							this.Inputmoney1 = res.res.data.re_money
						}
					},
				});
			},
			formSubmit() {
				if (this.Inputmoney == '' || this.Inputmoney == null) {
					uni.showToast({
						title: '请输入YLDA',
						icon: 'none'
					})
					return
				}
				uni.request({
					url: "/user/yldaUsdt",
					method: 'POST',
					data: {
						ylda: this.Inputmoney,
					},
					success: (res) => {
						if (res.res.code == 1) {
							this.$wanlshop.msg(res.res.msg);
							setTimeout(() => {
								uni.reLaunch({
									url: '/pages/newPage/myOtc'
								})
							}, 500);
						}
					},
				});
			},
			blur() {
				this.usdtblreMoney()
			},
		}
	};
</script>

<style lang="scss">
	page {
		background: #fff;
	}

	.Menu {
		background: #fff;

		.cardBox {
			padding: 0 24rpx;
		}

		.card {
			width: 100%;
			height: 294rpx;
			background: url("../../static/images/index/gupiao1.png") no-repeat;
			background-size: 100% 100%;
			margin-top: 40rpx;
			text-align: center;
			color: #fff;
			font-size: 28rpx;
		}

		.jf {
			margin-top: 20rpx;
			display: flex;
			justify-content: space-around;
			align-items: center;
		}

		.money {
			font-size: 60rpx;
			padding-top: 30rpx;
		}

		.all {
			margin-top: 10rpx;
		}

		.line {
			width: 2rpx;
			height: 90rpx;
			background: #fff;
		}

		.cardline {
			flex: 1;

			.num {
				font-weight: 600;
				font-size: 40rpx;
				color: #ffffff;
			}
		}

		.details {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 24rpx;
			margin-top: 28rpx;
			color: #666666;

			.extract {
				padding: 10rpx 20rpx;
				border-radius: 8rpx 8rpx 8rpx 8rpx;
				border: 2rpx solid #e34544;
				font-weight: 400;
				font-size: 28rpx;
				color: #e34544;
				margin-left: 20rpx;
			}
		}

		.listbox {
			padding: 30rpx;
			margin-top: 34rpx;
			position: relative;

			.bg {
				padding: 50rpx;
				background: #f9f9f9;
				border-radius: 30rpx;
				margin-bottom: 40rpx;

				.assets {
					.assetsT {
						display: flex;
						align-items: center;
						justify-content: space-between;
						margin-bottom: 20rpx;

						.title {
							font-weight: 400;
							font-size: 30rpx;
							color: #000;
							line-height: 48rpx;
							font-weight: bold;
						}

						.pick {
							font-weight: 400;
							font-size: 24rpx;
							color: #666666;
							line-height: 48rpx;
							min-width: 112rpx;
							display: flex;
							align-items: center;
							justify-content: space-between;
						}
					}

					.assetsM {
						display: flex;
						align-items: center;
						justify-content: space-between;

						.assetsInput {
							width: 50%;

							/deep/.u-input__content__field-wrapper__field,
							.Inputmoney1 {
								font-weight: 600;
								font-size: 40rpx !important;
								color: #eb5641 !important;
								line-height: 48rpx !important;

								.uni-input-input {
									text-align: right;
								}
							}

						}

						.assetsmMoney {
							font-weight: 400;
							font-size: 40rpx;
							color: #000;
							line-height: 48rpx;
							font-weight: bold;
						}
					}
				}
			}

			.dhJT {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 100rpx;
				height: 100rpx;
				background: #fff;
				border-radius: 100%;
				position: absolute;
				top: 40%;
				left: 50%;
				margin-left: -50rpx;

				.up {
					margin: -20rpx 0 0 -15rpx;
				}

				/deep/.u-icon__icon {
					font-weight: bold !important;
				}
			}
		}
	}

	.uni-btn-v {
		width: 702rpx;
		height: 96rpx;
		background: #eb5641;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		margin-top: 40rpx;
		font-weight: 400;
		font-size: 28rpx;
		color: #ffffff;
		line-height: 96rpx;
		margin-top: 80rpx;
	}
</style>